<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>z-index失效</title>
    <style>
        .box {
            position: relative;
            width: 500px;
            height: 500px;
            border: 1px solid red;
            background-color: pink;
        }
        .sub {
            float: left;
            position: absolute;
            width: 300px;
            height: 300px;
            border: 1px solid #333;
            background-color: orange;
            z-index: 999;
        }
        .son {
            position: absolute;
            width: 300px;
            height: 300px;
            border: 1px solid #666;
            background-color: purple;
        }
    </style>

</head>

<body>
    <!-- 父元素设置relative也可以设置z-index -->
    <div class="box">
        <div class="sub">
        </div>
        <div class="son"></div>
    </div>
</body>

</html>